import {
  createStoreBindings
} from 'mobx-miniprogram-bindings'
import {
  store
} from '../../store/index.js'
Page({
  data: {
    top: 0,
  },
  onFocus: function () {
    wx.navigateTo({
      url: '/pagesA/pages/search/index',
    })
  },
  goDetail(e) {
    wx.setStorageSync('goodsDetails', e.detail.data)
    wx.navigateTo({
      url: `/pagesA/pages/goodsDetails/index`,
    })
  },
  onLoad: function (options) {
    this.storeBindings = createStoreBindings(this, {
      // 属性
      store,
      fields: [
        "classList",
        "goodsDetails",
        "goods_list"
      ],
      actions: [
        "modifyGoodsDetails",
        "getProductsList"
      ]
    })


    wx.getSystemInfo({
      success: (res) => {
        this.setData({
          top: res.safeArea.top
        })
      }
    })
    this.getProductsList()
  },
  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {
    // 卸载mobx
    this.storeBindings.destroyStoreBindings()
  },
});
